<?php
 header('content-type:text/html;charset=utf-8'); 
	$lot=$_GET["lot"];
	$dbName = "sqlsrv:Server=172.31.3.12,1433;Database=UFDATA_001_2017";   //emc3030
	$dbUser = "sa";    //
	$dbPassword = "TDled!2018";    //
	$db = new PDO($dbName, $dbUser, $dbPassword);   
	//$sql = "select MoId from  mom_order where MoCode ='".$lot."' ";
	//print_r($sql);
	//$res = $db->query($sql);
	//print_r($res);
	// while ($row = $res->fetch()){
	//	print_r($MoDId=$row['MoId']);
	//}	
   
	$sql = "select MoDId,InvCode from mom_orderdetail where moid=(select MoId from  mom_order where MoCode ='".$lot."') ";  //
	//print_r($sql);
	$res = $db->query($sql);
	//print_r($res);
	$MoDId="";
	$InvCode="";
	//$row = null;
	 while ($row = $res->fetch()){
		$MoDId=$row['MoDId'];
		$InvCode=$row['InvCode'];
	}	
	$sql = "select invcode,Qty from mom_moallocate where MoDId = '".$MoDId."' and invcode like 'A%' ";//17620T4003-7250613
	$res2 = $db->query($sql);
		//
	$sub_invcode="";
	$Qty="";
	while ($row = $res2->fetch()){
	  $sub_invcode= $row['invcode'];
	  $Qty=$row['Qty'];
	 }
	
	$sql = "select cInvName,cInvDefine10,cInvDefine3,cInvDefine2 from Inventory where cinvcode='".$sub_invcode."' ";
	$res = $db->query($sql);
	$cInvName="";
	$ele="";
	$light="";
	$wave="";
	while ($row = $res->fetch()){
	  $cInvName= $row['cInvName'];
	  $ele=$row['cInvDefine10'];
	  $light= $row['cInvDefine3'];
	  $wave=$row['cInvDefine2'];
	 }
	
	$res = null;
	$res2 = null;
	$db = null;
    $wo= $InvCode.",".$sub_invcode.",".$Qty.",".$cInvName.",".$ele.",".$light.",".$wave;               	
	 print_r($wo);
